class Solution {
public:
    int FindGreatestSumOfSubArray(vector<int>& arr) {
        int n = arr.size();
        vector<int> dp(n, 0);
        dp[0] = arr[0];
        for (int i = 1; i < n; ++i) {
            dp[i] = max(dp[i-1] + arr[i], arr[i]);
        }
        return *max_element(dp.begin(), dp.end());
    }
};